{include file="public/header" /}
<body class="bgc">
<div class="header">
    <i class="layui-icon layui-icon-left"></i> 切换账号
</div>

<ul class="number-list">
    <li>
        <p class="flex-center">
            <img src="{if $user.photo}{$user.photo}{else}cache('system')['default_photo']{/if}" alt="">
        </p>
        <div>
            <p>{$user.code}【{$user.nickname}】</p>
            <p>{:substrCut($user.mobile)}</p>
        </div>
        <span>当前</span>
    </li>
</ul>

<div class="number-title">已绑定账号<span>点击用户头像一键切换登录已绑定账号</span></div>

<ul class="number-list">
    {foreach name="list" item="vo"}
    <li>

        <p class="flex-center login" data-id="{$vo.id}">
            <img src="{if $vo.take.photo}{$vo.take.photo}{else}{:cache('system')['default_photo']}{/if}" alt="">
        </p>
        <div class="login" data-id="{$vo.id}">
            <p>{$vo.take.code}【{$vo.take.nickname}】</p>
            <p>{:substrCut($vo.take.mobile)}</p>
        </div>


        <img src="/static/index/img/icon14.png" data-id="{$vo.id}" class="del" alt="">
    </li>
    {/foreach}
</ul>
<p class="save upd-save add-account">添加账号</p>
<div class="add" style="display: none">

    <form action="{:url('user/addAccount')}" method="post" class="form layui-form">
        <ul class="upd-list">
            <li>
                <p>会员编号</p>
                <input type="text" name="code" placeholder="请填写会员编号" ay-verify="required"
                       lay-reqtext="请填写会员编号"
                       lay-verType="tips">
            </li>
            <li>
                <p>密码</p>
                <input type="password" name="password" placeholder="请填写密码" lay-verify="required"
                       lay-reqtext="请填写登录密码"
                       lay-verType="tips">
            </li>
        </ul>

        <p class="save save-fixed upd-save" lay-submit lay-filter="save" formObj=".form">保存</p>
    </form>
</div>
</body>
{include file="public/footer"/}
<script>
    $('.add-account').click(function () {
        layer.open({
            type: 1,
            offset: 'b',
            anim: 'slideUp', // 从下往上
            title: '添加账号',
            shadeClose: true,
            shade: 0.8,
            area: ['100%', '50%'],
            content: $(".add") //iframe的url
        });
    });
    $(".del").click(function () {
        var id = $(this).attr('data-id');
        layer.confirm('是否删除账号？', {title: '请确认'}, function (index) {
            _ajax('{:url("user/editAccount")}', {id: id, type: 1});
        });
    });
    $(".login").click(function () {
        var id = $(this).attr('data-id');
        layer.confirm('确定切换为此账号？', {title: '请确认'}, function (index) {
            _ajax('{:url("user/editAccount")}', {id: id, type: 2});
        });
    });
</script>
</html>